<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="content-type" content="text/html; charset=UTF-8" />
    <title>广告管理</title>
    <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}" type="text/css" media="screen" />
    <script type="text/javascript" th:src="@{/xheditor/jquery/jquery-1.4.4.min.js}"></script>
    <script type="text/javascript" th:src="@{/xheditor/xheditor-1.1.14-zh-cn.min.js}"></script>

    <script type="text/javascript">
        $(pageInit);
        function pageInit()
        {
            $('#elm1').xheditor({
                tools:'full',
                skin:'default',
                internalScript:false,
                html5Upload:false,
                upImgUrl:"/admin/banner/editorPicUpload",
                upImgExt:"jpg,jpeg,gif,png"
            });

            //banner上传预览
            $("#selectImage").change(function() {
                var $file = $(this);
                var fileObj = $file[0];
                var windowURL = window.URL || window.webkitURL;
                var dataURL;
                var $img = $("#bannerImage");
                if(fileObj && fileObj.files && fileObj.files[0]){
                    dataURL = windowURL.createObjectURL(fileObj.files[0]);
                    $img.attr('src',dataURL);
                    $('#selectImage').hide();
                }else{
                    dataURL = $file.val();
                    var imgObj = document.getElementById("bannerImage");
                    imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                    imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;
                }
            });
        }
    </script>
</head>
<body>


<div class="panel panel-default">
    <ol class="breadcrumb">
        <li><a href="/admin/banner/">广告管理</a></li>
        <li class="active">添加广告</li>
    </ol>


    <form id="editorForm" method="post" enctype="multipart/form-data" action="/admin/banner/addBanner">
        <table class="table">
            <tr>
                <th><span>图片</span></th>
                <th>
                    <image class="img-responsive" id="bannerImage" style="width: 50px;height: 50px;"></image>
                    <input id="selectImage" type="file" name="bannerFile" />
                </th>
            </tr>
            <tr rowspan="4">
                <th><span>广告详情</span></th>
                <th>
                    <textarea id="elm1" name="editorContent" style="width: 100%;height: 100%;">
                    </textarea>
                </th>
            </tr>
            <tr>
                <th colspan="2"><button class="btn btn-default" type="submit">发布</button></th>
            </tr>
        </table>
    </form>
</div>



</body>
</html>